package com.sgcc.pda.sdk.utils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sgcc.pda.baselibrary.utils.SPUtil;
import com.sgcc.pda.mdrh.app.ZoomApplication;
import com.sgcc.pda.sdk.entity.table.UserInfo;
import com.sgcc.pda.sdk.utils.db.SharepreferenceUtil;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by cj on 2020/8/25.
 */
public class ZoomSPUtils {

    /**
     * sp文件的所有key
     */
    private static final String KEY_USER_CODE = "USER_CODE";//用户名
    private static final String KEY_USB_ENABLE = "USB_ENABLE";//是否使用USB
    private static final String KEY_MIP_ENABLE = "MIP_ENABLE";//是否使用MIP
    private static final String KEY_SAFETY_UNIT_UNLOCK = "SAFETY_UNIT_UNLOCK";//安全单元解锁开关
    private static final String KEY_MIP_SWITCH = "MIP_SWITCH";//MIP开关
    private static final String KEY_MIP_PROVINCE = "MIP_PROVINCE";//MIP网省
    private static final String KEY_MIP_APP_ID = "MIP_APP_ID";//
    private static final String KEY_MIP_APP_SECRET = "MIP_APP_SECRET";//
    private static final String KEY_MIP_APP_CODE = "MIP_APP_CODE";//
    private static final String KEY_MIP_ONLINE_IP = "MIP_ONLINE_IP";//MIP登录IP
    private static final String KEY_MIP_ONLINE_PORT = "MIP_ONLINE_PORT";//MIP登录端口
    private static final String KEY_MIP_LOCAL_IP = "MIP_LOCAL_IP";//MIP登录IP
    private static final String KEY_MIP_LOCAL_PORT = "MIP_LOCAL_PORT";//MIP登录端口
    private static final String KEY_COMM_IP_USB = "COMM_IP_USB";//usb登录ip
    private static final String KEY_COMM_PORT_USB = "COMM_PORT_USB";//usb登录端口
    private static final String KEY_COMM_IP = "COMM_IP";//登录ip
    private static final String KEY_COMM_PORT = "COMM_PORT";//登录端口
    private static final String KEY_COMM_APN_NAME = "COMM_APN_NAME";//
    private static final String KEY_COMM_APN = "COMM_APN";//
    private static final String KEY_COMM_USER_NAME = "COMM_USER_NAME";//
    private static final String KEY_COMM_USER_KEY = "KEY_COMM_USER_PWD";//
    private static final String KEY_SAFETY_UNIT_KEY = "SAFETY_UNIT_PWD";//
    private static final String KEY_SAFETY_UNIT_UNLOCK_KEY = "SAFETY_UNIT_UNLOCK_PWD";//
    private static final String KEY_SO_LOAD_ADDRESS = "SO_LOAD_ADDRESS";//
    private static final String KEY_IS_NEW_PROTOCOL = "IS_NEW_PROTOCOL";//
    private static final String KEY_SO_INIT_ORDER = "SO_INIT_ORDER";//
    private static final String KEY_CALLER_PACKAGE_NAME = "CALLER_PACKAGE_NAME";//调用者包名
    private static final String KEY_CALLER_USER_CODE = "CALLER_USER_CODE";//
    private static final String KEY_CALLER_ORG_NO = "CALLER_ORG_NO";//
    private static final String KEY_CALLER_SYS_CODE = "CALLER_SYS_CODE";//
    private static final String KEY_BUSINESS_PKG_NAME = "BUSINESS_PKG_NAME";//
    private static final String KEY_BUSINESS_START_ACTIVITY = "BUSINESS_START_ACTIVITY";//
    private static final String KEY_BUSINESS_TYPE = "BUSINESS_TYPE";//
    private static final String KEY_USER_NAME = "USER_NAME";//用户名
    private static final String KEY_USER_ID = "USER_ID";//用户ID
    private static final String KEY_BH_USER_CODE = "BH_USER_CODE";//闭环用户ID
    private static final String KEY_SAFETY_UNIT_VERSION = "SAFETY_UNIT_VERSION";//
    private static final String KEY_CESAM_VERSION = "CESAM_VERSION";//
    private static final String KEY_YESAM_VERSION = "YESAM_VERSION";//
    private static final String KEY_COMM_LOGIN_KEY = "COMM_LOGIN_PWD";//登录密码
    private static final String KEY_SIM_CARD_SN = "SIM_CARD_SN";//
    private static final String KEY_LOGIN_FLAG = "LOGIN_FLAG";//
    private static final String KEY_OPERATOR_NO = "OPERATOR_NO";//
    private static final String KEY_OPERATOR_NAME = "OPERATOR_NAME";//
    private static final String KEY_OPERATION_NO = "OPERATION_NO";//
    private static final String KEY_IMEI_NO = "IMEI_NO";//
    private static final String KEY_UID = "UID";//
    private static final String KEY_MAC = "MAC";//
    private static final String KEY_ROLE_ID = "ROLE_ID";//
    //安全单元信息
    private static final String KEY_OPERATOR = "OPERATOR";//操作者代码
    private static final String KEY_SOFT_VERSION = "SOFT_VERSION";//安全单元软件版本号
    private static final String KEY_HARD_VERSION = "HARD_VERSION";//安全单元硬件版本号
    private static final String KEY_SYSTEM_VERSION = "SYSTEM_VERSION";//操作系统版本号
    private static final String KEY_MAIN_STATION_CERTIFICATE = "MAIN_STATION_CERTIFICATE";//主站证书
    private static final String KEY_TERMINAL_CERTIFICATE = "TERMINAL_CERTIFICATE";//终端证书
    private static final String KEY_MAIN_STATION_CERTIFICATE_VERSION = "MAIN_STATION_CERTIFICATE_VERSION";//主站证书版本号
    private static final String KEY_MAIN_STATION_CERTIFICATE_NO = "MAIN_STATION_CERTIFICATE_NO";//主站证书序列号
    private static final String KEY_TERMINAL_CERTIFICATE_VERSION = "TERMINAL_CERTIFICATE_VERSION";//终端证书版本号
    private static final String KEY_TERMINAL_CERTIFICATE_NO = "TERMINAL_CERTIFICATE_NO";//终端证书序列号
    private static final String KEY_CESAM_NUM = "CESAM_NUM";//C-ESAM序列号
    private static final String KEY_YESAM_NUM = "YESAM_NUM";//Y-ESAM序列号
    private static final String KEY_COUNTER = "COUNTER";//Yesam计数器

    private static final String KEY_LOGIN_MODE = "LOGIN_MODE";//0账号 ，1人脸
    private static final String KEY_M1 = "M1";//
    private static final String KEY_SO_VERSION = "SO_VERSION";//
    private static final String KEY_APP_VERSION_CODE = "APP_VERSION_CODE";//软件版本号
    private static final String KEY_LOG_SAVE_DAYS = "LOG_SAVE_DAYS";//日志存储天数
    /**
     * 用户信息存储
     * getHandsetUsers接口返回的绑定用户。
     */
    private static final String KEY_PERSON = "PERSON";//离线登录用户信息，包括
    private static final String IS_LOGIN = "IS_LOGIN";//是否是登录状态
    private static final String LOG_OUT_NUM = "LOG_OUT_NUM";//注销次数记录
    private static final String KEY_ENCRIPTION = "ENCRIPTION";//是否加密传输

    public static void setUserCode(String userCode) {
        SPUtil.getInstance().put(KEY_USER_CODE, userCode);
    }

    public static String getUserCode() {
        return SPUtil.getInstance().getString(KEY_USER_CODE, "");
    }

    public static void setCommUsbEnable(boolean usbEnable) {
        SPUtil.getInstance().put(KEY_USB_ENABLE, usbEnable);
    }

    public static boolean getCommUsbEnable() {
        return SPUtil.getInstance().getBoolean(KEY_USB_ENABLE, false);
    }

    public static void setMipLoginEnable(boolean enable) {
        SPUtil.getInstance().put(KEY_MIP_ENABLE, enable);
    }

    public static boolean getMipLoginEnable() {
        return SPUtil.getInstance().getBoolean(KEY_MIP_ENABLE, false);
    }

    public static void setSafetyUnitUnlock(boolean enable) {
        SPUtil.getInstance().put(KEY_SAFETY_UNIT_UNLOCK, enable);
    }

    public static boolean getSafetyUnitUnlock() {
        return SPUtil.getInstance().getBoolean(KEY_SAFETY_UNIT_UNLOCK, false);
    }

    public static void setMipSwitch(boolean enable) {
        SPUtil.getInstance().put(KEY_MIP_SWITCH, enable);
    }

    public static boolean getMipSwitch() {
        return SPUtil.getInstance().getBoolean(KEY_MIP_SWITCH, false);
    }

    public static void setMipProvince(String str) {
        SPUtil.getInstance().put(KEY_MIP_PROVINCE, str);
    }

    public static String getMipProvince() {
        return SPUtil.getInstance().getString(KEY_MIP_PROVINCE, "");
    }

    public static void setMipAppId(String str) {
        SPUtil.getInstance().put(KEY_MIP_APP_ID, str);
    }

    public static String getMipAppId() {
        return SPUtil.getInstance().getString(KEY_MIP_APP_ID, "");
    }

    public static void setMipAppSecret(String str) {
        SPUtil.getInstance().put(KEY_MIP_APP_SECRET, str);
    }

    public static String getMipAppSecret() {
        return SPUtil.getInstance().getString(KEY_MIP_APP_SECRET, "");
    }

    public static void setMipAppCode(String str) {
        SPUtil.getInstance().put(KEY_MIP_APP_CODE, str);
    }

    public static String getMipAppCode() {
        return SPUtil.getInstance().getString(KEY_MIP_APP_CODE, "");
    }

    public static void setMipOnlineIp(String str) {
        SPUtil.getInstance().put(KEY_MIP_ONLINE_IP, str);
    }

    public static String getMipOnlineIp() {
        return SPUtil.getInstance().getString(KEY_MIP_ONLINE_IP, "");
    }

    public static void setMipOnlinePort(String str) {
        SPUtil.getInstance().put(KEY_MIP_ONLINE_PORT, str);
    }

    public static String getMipOnlinePort() {
        return SPUtil.getInstance().getString(KEY_MIP_ONLINE_PORT, "");
    }

    public static void setMipLocalIp(String str) {
        SPUtil.getInstance().put(KEY_MIP_LOCAL_IP, str);
    }

    public static String getMipLocalIp() {
        return SPUtil.getInstance().getString(KEY_MIP_LOCAL_IP, "");
    }

    public static void setMipLocalPort(String str) {
        SPUtil.getInstance().put(KEY_MIP_LOCAL_PORT, str);
    }

    public static String getMipLocalPort() {
        return SPUtil.getInstance().getString(KEY_MIP_LOCAL_PORT, "");
    }

    public static void setCommIpUSB(String str) {
        SPUtil.getInstance().put(KEY_COMM_IP_USB, str);
    }

    public static String getCommIpUSB() {
        return SPUtil.getInstance().getString(KEY_COMM_IP_USB, "");
    }

    public static void setCommPortUSB(String str) {
        SPUtil.getInstance().put(KEY_COMM_PORT_USB, str);
    }

    public static String getCommPortUSB() {
        return SPUtil.getInstance().getString(KEY_COMM_PORT_USB, "");
    }

    public static void setCommIp(String str) {
        SPUtil.getInstance().put(KEY_COMM_IP, str);
    }

    public static String getCommIp() {
        return SPUtil.getInstance().getString(KEY_COMM_IP, "");
    }

    public static void setCommPort(String str) {
        SPUtil.getInstance().put(KEY_COMM_PORT, str);
    }

    public static String getCommPort() {
        return SPUtil.getInstance().getString(KEY_COMM_PORT, "");
    }

    public static void setCommApnName(String str) {
        SPUtil.getInstance().put(KEY_COMM_APN_NAME, str);
    }

    public static String getCommApnName() {
        return SPUtil.getInstance().getString(KEY_COMM_APN_NAME, "");
    }

    public static void setCommApn(String str) {
        SPUtil.getInstance().put(KEY_COMM_APN, str);
    }

    public static String getCommApn() {
        return SPUtil.getInstance().getString(KEY_COMM_APN, "");
    }


    public static void setCommUserName(String str) {
        SPUtil.getInstance().put(KEY_COMM_USER_NAME, str);
    }

    public static String getCommUserName() {
        return SPUtil.getInstance().getString(KEY_COMM_USER_NAME, "");
    }


    public static void setCommUserPswd(String str) {
        SPUtil.getInstance().put(KEY_COMM_USER_KEY, str);
    }

    public static String getCommUserPswd() {
        return SPUtil.getInstance().getString(KEY_COMM_USER_KEY, "");
    }


    public static void setSafetyUnitPwd(String str) {
        SPUtil.getInstance().put(KEY_SAFETY_UNIT_KEY, str);
    }

    public static String getSafetyUnitPwd() {
        return SPUtil.getInstance().getString(KEY_SAFETY_UNIT_KEY, "");
    }

    public static void setSafetyUnitUnlockPwd(String str) {
        SPUtil.getInstance().put(KEY_SAFETY_UNIT_UNLOCK_KEY, str);
    }

    public static String getSafetyUnitUnlockPwd() {
        return SPUtil.getInstance().getString(KEY_SAFETY_UNIT_UNLOCK_KEY, "");
    }

    public static void setSoLoadAddress(String str) {
        SPUtil.getInstance().put(KEY_SO_LOAD_ADDRESS, str);
    }

    public static String getSoLoadAddress() {
        return SPUtil.getInstance().getString(KEY_SO_LOAD_ADDRESS, "");
    }

    public static void setIsNewProtcol(boolean bool) {
        SPUtil.getInstance().put(KEY_IS_NEW_PROTOCOL, bool);
    }

    public static boolean getIsNewProtcol() {
        return SPUtil.getInstance().getBoolean(KEY_IS_NEW_PROTOCOL, true);
    }

    public static void setSoInitOrder(int num) {
        SPUtil.getInstance().put(KEY_SO_INIT_ORDER, num);
    }

    public static int getSoInitOrder() {
        return SPUtil.getInstance().getInt(KEY_SO_INIT_ORDER, 3);
    }

    public static void setCallerPackageName(String str) {
        SPUtil.getInstance().put(KEY_CALLER_PACKAGE_NAME, str);
    }

    public static String getCallerPackageName() {
        return SPUtil.getInstance().getString(KEY_CALLER_PACKAGE_NAME, "");
    }

    public static void setCallerUserCode(String str) {
        SPUtil.getInstance().put(KEY_CALLER_USER_CODE, str);
    }

    public static String getCallerUserCode() {
        return SPUtil.getInstance().getString(KEY_CALLER_USER_CODE, "");
    }

    public static void setCallerOrgNo(String str) {
        SPUtil.getInstance().put(KEY_CALLER_ORG_NO, str);
    }

    public static String getCallerOrgNo() {
        return SPUtil.getInstance().getString(KEY_CALLER_ORG_NO, "");
    }

    public static void setCallerSysCode(String str) {
        SPUtil.getInstance().put(KEY_CALLER_SYS_CODE, str);
    }

    public static String getCallerSysCode() {
        return SPUtil.getInstance().getString(KEY_CALLER_SYS_CODE, "");
    }

    public static void setBusinessPackageName(String str) {
        SPUtil.getInstance().put(KEY_BUSINESS_PKG_NAME, str);
    }

    public static String getBusinessPackageName() {
        return SPUtil.getInstance().getString(KEY_BUSINESS_PKG_NAME, "");
    }

    public static void setBusinessStartActivity(String str) {
        SPUtil.getInstance().put(KEY_BUSINESS_START_ACTIVITY, str);
    }

    public static String getBusinessStartActivity() {
        return SPUtil.getInstance().getString(KEY_BUSINESS_START_ACTIVITY, "");
    }

    public static void setBusinessType(String str) {
        SPUtil.getInstance().put(KEY_BUSINESS_TYPE, str);
    }

    public static String getBusinessType() {
        return SPUtil.getInstance().getString(KEY_BUSINESS_TYPE, "");
    }

    public static void setUserName(String str) {
        SPUtil.getInstance().put(KEY_USER_NAME, str);
    }

    public static String getUserName() {
        return SPUtil.getInstance().getString(KEY_USER_NAME, "");
    }

    public static void setUserId(String str) {
        SPUtil.getInstance().put(KEY_USER_ID, str);
    }

    public static String getUserId() {
        return SPUtil.getInstance().getString(KEY_USER_ID, "");
    }

    public static void setBHUserCode(String str) {
        SPUtil.getInstance().put(KEY_BH_USER_CODE, str);
    }

    public static String getBHUserCode() {
        return SPUtil.getInstance().getString(KEY_BH_USER_CODE, "");
    }

    public static void setSafetyUnitVersion(int num) {
        SPUtil.getInstance().put(KEY_SAFETY_UNIT_VERSION, num);
    }

    public static int getSafetyUnitVersion() {
        return SPUtil.getInstance().getInt(KEY_SAFETY_UNIT_VERSION, 2);
    }

    public static void setCesamVersion(String str) {
        SPUtil.getInstance().put(KEY_CESAM_VERSION, str);
    }

    public static String getCesamVersion() {
        return SPUtil.getInstance().getString(KEY_CESAM_VERSION, "");
    }

    public static void setYesamVersion(String str) {
        SPUtil.getInstance().put(KEY_YESAM_VERSION, str);
    }

    public static String getYesamVersion() {
        return SPUtil.getInstance().getString(KEY_YESAM_VERSION, "");
    }

    public static void setCommLoginPwd(String str) {
        SPUtil.getInstance().put(KEY_COMM_LOGIN_KEY, str);
    }

    public static String getCommLoginPwd() {
        return SPUtil.getInstance().getString(KEY_COMM_LOGIN_KEY, "");
    }

    public static void setSimCardSn(String str) {
        SPUtil.getInstance().put(KEY_SIM_CARD_SN, str);
    }

    public static String getSimCardSn() {
        return SPUtil.getInstance().getString(KEY_SIM_CARD_SN, "");
    }

    public static void setLoginFlag(String str) {
        SPUtil.getInstance().put(KEY_LOGIN_FLAG, str);
    }

    public static String getLoginFlag() {
        return SPUtil.getInstance().getString(KEY_LOGIN_FLAG, "");
    }

    public static void setOperatorNo(String str) {
        SPUtil.getInstance().put(KEY_OPERATOR_NO, str);
    }

    public static String getOperatorNo() {
        return SPUtil.getInstance().getString(KEY_OPERATOR_NO, "");
    }

    public static void setOperationNo(String str) {
        SPUtil.getInstance().put(KEY_OPERATION_NO, str);
    }

    public static String getOperationNo() {
        return SPUtil.getInstance().getString(KEY_OPERATION_NO, "");
    }

    public static void setImeiNo(String str) {
        SPUtil.getInstance().put(KEY_IMEI_NO, str);
    }

    public static String getImeiNo() {
        return SPUtil.getInstance().getString(KEY_IMEI_NO, "");
    }

    public static void setUid(String str) {
        SPUtil.getInstance().put(KEY_UID, str);
    }

    public static String getUid() {
        return SPUtil.getInstance().getString(KEY_UID, "");
    }

    public static void setMac(String str) {
        SPUtil.getInstance().put(KEY_MAC, str);
    }

    public static String getMac() {
        return SPUtil.getInstance().getString(KEY_MAC, "");
    }

    public static void setRoleId(String str) {
        SPUtil.getInstance().put(KEY_ROLE_ID, str);
    }

    public static String getRoleId() {
        return SPUtil.getInstance().getString(KEY_ROLE_ID, "");
    }

    public static void setOperator(String str) {
        SPUtil.getInstance().put(KEY_OPERATOR, str);
    }

    public static String getOperator() {
        return SPUtil.getInstance().getString(KEY_OPERATOR, "");
    }

    public static void setSoftVersion(String str) {
        SPUtil.getInstance().put(KEY_SOFT_VERSION, str);
    }

    public static String getSoftVersion() {
        return SPUtil.getInstance().getString(KEY_SOFT_VERSION, "");
    }

    public static void setHardVersion(String str) {
        SPUtil.getInstance().put(KEY_HARD_VERSION, str);
    }

    public static String getHardVersion() {
        return SPUtil.getInstance().getString(KEY_HARD_VERSION, "");
    }

    public static void setSystemVersion(String str) {
        SPUtil.getInstance().put(KEY_SYSTEM_VERSION, str);
    }

    public static String getSystemVersion() {
        return SPUtil.getInstance().getString(KEY_SYSTEM_VERSION, "");
    }

    public static void setMainStationCertificate(String str) {
        SPUtil.getInstance().put(KEY_MAIN_STATION_CERTIFICATE, str);
    }

    public static String getMainStationCertificate() {
        return SPUtil.getInstance().getString(KEY_MAIN_STATION_CERTIFICATE, "");
    }

    public static void setTerminalCertificate(String str) {
        SPUtil.getInstance().put(KEY_TERMINAL_CERTIFICATE, str);
    }

    public static String getTerminalCertificate() {
        return SPUtil.getInstance().getString(KEY_TERMINAL_CERTIFICATE, "");
    }

    public static void setMainStationCertificateVersion(String str) {
        SPUtil.getInstance().put(KEY_MAIN_STATION_CERTIFICATE_VERSION, str);
    }

    public static String getMainStationCertificateVersion() {
        return SPUtil.getInstance().getString(KEY_MAIN_STATION_CERTIFICATE_VERSION, "");
    }

    public static void setMainStationCertificateNo(String str) {
        SPUtil.getInstance().put(KEY_MAIN_STATION_CERTIFICATE_NO, str);
    }

    public static String getMainStationCertificateNo() {
        return SPUtil.getInstance().getString(KEY_MAIN_STATION_CERTIFICATE_NO, "");
    }

    public static void setTerminalCertificateVersion(String str) {
        SPUtil.getInstance().put(KEY_TERMINAL_CERTIFICATE_VERSION, str);
    }

    public static String getTerminalCertificateVersion() {
        return SPUtil.getInstance().getString(KEY_TERMINAL_CERTIFICATE_VERSION, "");
    }

    public static void setTerminalCertificateNo(String str) {
        SPUtil.getInstance().put(KEY_TERMINAL_CERTIFICATE_NO, str);
    }

    public static String getTerminalCertificateNo() {
        return SPUtil.getInstance().getString(KEY_TERMINAL_CERTIFICATE_NO, "");
    }

    public static void setOpratorName(String str) {
        SPUtil.getInstance().put(KEY_OPERATOR_NAME, str);
    }

    public static String getOpratorName() {
        return SPUtil.getInstance().getString(KEY_OPERATOR_NAME, "");
    }

    public static void setCesamNum(String str) {
        SPUtil.getInstance().put(KEY_CESAM_NUM, str);
    }

    public static String getCesamNum() {
        return SPUtil.getInstance().getString(KEY_CESAM_NUM, "");
    }

    public static void setYesamNum(String str) {
        SPUtil.getInstance().put(KEY_YESAM_NUM, str);
    }

    public static String getYesamNum() {
        return SPUtil.getInstance().getString(KEY_YESAM_NUM, "");
    }

    public static void setLoginMode(String str) {
        SPUtil.getInstance().put(KEY_LOGIN_MODE, str);
    }

    public static String getLoginMode() {
        return SPUtil.getInstance().getString(KEY_LOGIN_MODE, "");
    }

    public static void setCounter(String str) {
        SPUtil.getInstance().put(KEY_COUNTER, str);
    }

    public static String getCounter() {
        return SPUtil.getInstance().getString(KEY_COUNTER, "");
    }

    public static void setM1(String str) {
        SPUtil.getInstance().put(KEY_M1, str);
    }

    public static String getM1() {
        return SPUtil.getInstance().getString(KEY_M1, "");
    }

    public static void setSoVersion(String str) {
        SPUtil.getInstance().put(KEY_SO_VERSION, str);
    }

    public static String getSoVersion() {
        return SPUtil.getInstance().getString(KEY_SO_VERSION, "");
    }

    public static void setAppVersionCode(int num) {
        SPUtil.getInstance().put(KEY_APP_VERSION_CODE, num);
    }

    public static int getAppVersionCode() {
        return SPUtil.getInstance().getInt(KEY_APP_VERSION_CODE, 0);
    }

    public static void setLogSaveDays(int num) {
        SPUtil.getInstance().put(KEY_LOG_SAVE_DAYS, num);
    }

    public static int getLogSaveDays() {
        return SPUtil.getInstance().getInt(KEY_LOG_SAVE_DAYS, 1);
    }

    /**
     * 添加用户信息，根据user_code去重
     */
    public static void addPerson(String personBeanString) {
        //parse成bean
        UserInfo.User userInfo = new Gson().fromJson(personBeanString, UserInfo.User.class);
        //读取原有列表
        List<UserInfo.User> list = getPerson();
        //原有列表是否已经存在，没有则插入
        if (!isContainUser(userInfo, list)) {
            //插入原有列表并存储
            list.add(userInfo);
            SPUtil.getInstance().put(KEY_PERSON, new Gson().toJson(list));
        }
    }

    private static boolean isContainUser(UserInfo.User user, List<UserInfo.User> list) {
        for (UserInfo.User user1 : list) {
            if (user1.getUSER_CODE().equals(user.getUSER_CODE())) {
                return true;
            }
        }
        return false;
    }

    public static List<UserInfo.User> getPerson() {
        String persons = SPUtil.getInstance().getString(KEY_PERSON, "[]");
        Type type = new TypeToken<List<UserInfo.User>>() {
        }.getType();
        List<UserInfo.User> list = new Gson().fromJson(persons, type);
        return list;
    }

    public static void setIsLogin(boolean bool) {
        SPUtil.getInstance().put(IS_LOGIN, bool);
    }

    public static boolean getIsLogin() {
        return SPUtil.getInstance().getBoolean(IS_LOGIN, false);
    }

    public static void setLogoutNum(int num) {
        SPUtil.getInstance().put(LOG_OUT_NUM, num);
    }

    public static int getLogoutNum() {
        return SPUtil.getInstance().getInt(LOG_OUT_NUM, 0);
    }

    public static boolean getEncryption() {
        if ("0".equals(SharepreferenceUtil.getEncryptionMode(ZoomApplication.getInstance()))) {
            return false;
        }else {
            return true;
        }
    }
}
